package com.cqeec.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JMenuBar;
import javax.swing.JButton;
import java.awt.Insets;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
/**
 * 管理员主界面
 * @author 邓学强
 *
 */
public class MainInterface extends JFrame {

	private JPanel contentPane;
	private static JLabel label;
	private static MainInterface frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainInterface frame = new MainInterface();
					frame.setVisible(true);String path = "src/img/zsxx_bg.jpg";
					// 背景图片
					ImageIcon background = new ImageIcon(path);
					// 把背景图片显示在一个标签里面
					label = new JLabel(background);

					// 把标签的大小位置设置为图片刚好填充整个面板
					label.setBounds(0, 0, 1044, 648);
					// 把内容窗格转化为JPanel，否则不能用方法setOpaque()来使内容窗格透明
					JPanel imagePanel = (JPanel) frame.getContentPane();
					imagePanel.setOpaque(false);
					// 把背景图片添加到分层窗格的最底层作为背景
					frame.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));
					frame.setResizable(false);// 设置窗体不可拖动
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainInterface() {
		setTitle("管理员界面");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1045, 681);
		
		JMenuBar menuBar = new JMenuBar();
		menuBar.setMargin(new Insets(0, 0, 50, 0));
		setJMenuBar(menuBar);
		
		JMenu mnNewMenu = new JMenu("学生信息");
		mnNewMenu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 20));
		menuBar.add(mnNewMenu);
		
		JMenuItem menuItem_2 = new JMenuItem("添加学生");
		menuItem_2.addActionListener(new ActionListener() {
			/**
			 * 添加学生事件
			 */
			public void actionPerformed(ActionEvent arg0) {
				 contentPane.setVisible(false);// 设置主窗口内容不显示
				 AddStudents addStudents=new AddStudents();
				label.add(addStudents);
				addStudents.setLocation(100, 100); //子窗口居中
				addStudents.setVisible(true); //关闭主窗口后显示内部内部窗体内容
				
				
  			}
		});
		mnNewMenu.add(menuItem_2);
		
		JMenu mnNewMenu_1 = new JMenu("教师信息");
		mnNewMenu_1.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 20));
		menuBar.add(mnNewMenu_1);
		
		JMenuItem menuItem_4 = new JMenuItem("添加教师");
		menuItem_4.addActionListener(new ActionListener() {
			/**
			 * 添加教师
			 */
			public void actionPerformed(ActionEvent e) {
				 contentPane.setVisible(false);// 设置主窗口内容不显示
				 AddTeacher addTeacher=new AddTeacher();
				label.add(addTeacher);
				addTeacher.setLocation(100, 100); //子窗口居中
				addTeacher.setVisible(true); //关闭主窗口后显示内部内部窗体内容
			}
		});
		mnNewMenu_1.add(menuItem_4);
		
		JMenu menu = new JMenu("请假管理");
		menu.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 20));
		menuBar.add(menu);
		
		JMenuItem menuItem = new JMenuItem("修改请假");
		menu.add(menuItem);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
	}

}
